<?php
header("Content-Type: text/html;charset=utf-8");
include($_SERVER['DOCUMENT_ROOT']."/inc/config.php");
include($_SERVER['DOCUMENT_ROOT']."/inc/db.php");
$id=$_REQUEST['id']; //client id
$en_name1=$_REQUEST['en_name1'];
$cn_name1=$_REQUEST['cn_name1'];
$en_name2=$_REQUEST['en_name2'];
$cn_name2=$_REQUEST['cn_name2'];
$en_name3=$_REQUEST['en_name3'];
$cn_name3=$_REQUEST['cn_name3'];
$sec_use=$_REQUEST['sec_use'];
$sec_use_other=$_REQUEST['use_other'];
$sec_addr=$_REQUEST['sec_address'];
$sec_addr_other=$_REQUEST['address_other'];
$shareholder=$_REQUEST['shareholder'];
$name=$_REQUEST['name'];
$email=$_REQUEST['email'];
$tel=$_REQUEST['tel'];
$director=$_REQUEST['director'];
$tocken=$_REQUEST['tocken'];
$key='Wqs4A%3D';
$t=$_REQUEST['t'];
$s=$_REQUEST['s'];
$keys=sha1($key.$t.$key);
$tag=$_REQUEST['tag'];
if($keys!=$s && $tag!=1){
$res = urlencode("error");
$json=array(
'Status'=>'0',
'Msg'=>$res
);
		exit(json_encode($json));
}else{
	$sqladd="INSERT INTO company_setup
				( 	
					`en_name1`,
				    `cn_name1`, 
					`en_name2`, 
					`cn_name2`, 
					`en_name3`, 
					`cn_name3`, 
					`sec_use`, 
					`sec_use_other`, 
					`sec_addr`, 
					`sec_addr_other`, 
					`client_id`, 
					`addeddate`	,
					`name`,		
					`email`,		
					`tel`	
					
				) 
				VALUES 
				(
				  	'".trim($en_name1)."',
				  	'".trim($cn_name1)."',
				  	'".trim($en_name2)."',
				  	'".trim($cn_name2)."',
				  	'".trim($en_name3)."',	
				  	'".trim($cn_name3)."',
					'".trim($sec_use)."',
					'".trim($sec_use_other)."',
					'".trim($sec_addr)."',
					'".trim($sec_addr_other)."',
					'".trim($id)."',
					NOW()	,	
					'".trim($name)."',							  
					'".trim($email)."',							  
					'".trim($tel)."'						  
				 )";
            mysql_query("SET NAMES UTF8");//设置字符编码
			mysql_query($sqladd) or die("MYSQL Returned: " . mysql_error());
        $img_id=mysql_insert_id();

    $length=count($shareholder['address']);
    if($length>0){
        for ($i=0;$i<$length;$i++){
            $sql="INSERT INTO comp_partner(
`img_comp_id`,
`img_path`, 
`img_addr_path`, 
`img_date`, 
`img_sort`


) 
				VALUES 
				(
                                  '".trim($img_id)."',
				  	'".trim($shareholder['identity'][$i][0])."',
					'".trim($shareholder['address'][$i][0])."',
				  	'".trim(date('Y-m-d H:i:s'))."',
				  	'".trim($i+1)."'
)";
            mysql_query("SET NAMES UTF8");//设置字符编码
            mysql_query($sql);
        }
    }

    $length2=count($director['address']);
    if($length>0){
      for($k=0;$k<$length2;$k++){
            $sqld="INSERT INTO comp_director(
`img_comp_id`,
`img_path`, 
`img_addr_path`, 
`img_date`, 
`img_sort`


) 
				VALUES 
				(
                                  '".trim($img_id)."',
				  	'".$director['identity'][$k][0]."',
					'".$director['address'][$k][0]."',
				  	'".trim(date('Y-m-d H:i:s'))."',
				  	'".trim($k+1)."'
)";
            mysql_query("SET NAMES UTF8");//设置字符编码
            mysql_query($sqld);

        }

    }

$json=array(
'Status'=>'1',
'Msg'=>'Success'
);
exit(json_encode($json));
	
}


?>